package raft.entity;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Getter
@Setter
public class RvoteResult implements Serializable {

    /**
     * 任期
     */
        long term;
    /**
     * 是否投票
     */
        boolean vote;

        public RvoteResult(){};
       public RvoteResult(boolean vote){
           this.vote = vote;
       }

       public static RvoteResult fail(){
           return  new RvoteResult(false);
       }

       public static RvoteResult ok(){
        return  new RvoteResult(true);
      }


      public RvoteResult(Builder builder){
           setTerm(builder.term);
           setVote(builder.vote);
      }

      public static Builder newBuilder(){
           return new Builder();
      }

      public static final class Builder{
          long term;

          boolean vote;

          public Builder(){

          }

          public Builder term(long val){
              term = val;
              return this;
          }

          public Builder vote(boolean val){
              vote = val;
              return this;
          }

          public RvoteResult build(){
              return new RvoteResult(this);
          }







      }



}
